package com.lagou.mvcframework.pojo;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * 封装handler相关的信息
 */
public class Handler {

    private Object controller;

    private Method method;

    private Pattern pattern;

    private Map<String, Integer> paramIndexMapping;//key是参数名，value是参数位置（第几个参数）<name,2>

    private Boolean usePermission = true;//是否启用权限控制，默认启用

    private List<Pattern> userNamePatternList;//拥有权限的用户列表


    public Handler(Object controller, Method method, Pattern pattern) {
        this.controller = controller;
        this.method = method;
        this.pattern = pattern;
        this.paramIndexMapping = new HashMap<>();
        this.userNamePatternList = new ArrayList<>();
    }

    public Object getController() {
        return controller;
    }

    public void setController(Object controller) {
        this.controller = controller;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public Pattern getPattern() {
        return pattern;
    }

    public void setPattern(Pattern pattern) {
        this.pattern = pattern;
    }

    public Map<String, Integer> getParamIndexMapping() {
        return paramIndexMapping;
    }

    public void setParamIndexMapping(Map<String, Integer> paramIndexMapping) {
        this.paramIndexMapping = paramIndexMapping;
    }

    public Boolean getUsePermission() {
        return usePermission;
    }

    public void setUsePermission(Boolean usePermission) {
        this.usePermission = usePermission;
    }

    public List<Pattern> getUserNamePatternList() {
        return userNamePatternList;
    }

    public void setUserNamePatternList(List<Pattern> userNamePatternList) {
        this.userNamePatternList = userNamePatternList;
    }
}
